import { BaseItem } from "../../common/BaseItem";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { SkillConfig } from "../../../resource/SkillConfig";
import { EPetSkillSoul } from "../../../../../Message/Game/EPetSkillSoul";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { Tooltip } from "../../common/tooltip/Tooltip";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { EPetSkillType } from "../../../../../Message/Game/EPetSkillType";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { TSkill } from "../../../../../Message/Db/Tables/TSkill";
type int = number;
//class PetSkillItem
    
    export  class PetSkillItem extends BaseItem
    {
        constructor()
        {
            super();
            this.init();
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onSelectHandler);
            return;
        }

        /* internal  */init(): void
        {
            this._typeTxt = ObjCreate.createTextField("", 3, 3, 35, 35, this);
            return;
        }

        public get type(): int
        {
            return this._type;
        }

        public set type(arg1: int)
        {
            this._type = arg1;
            if (this._type != 0) 
            {
                if (this._type != 1) 
                {
                    if (this._type == 2) 
                    {
                        this._typeTxt.text = Language.getString(28060);
                    }
                }
                else 
                {
                    this._typeTxt.text = Language.getString(54137);
                }
            }
            else 
            {
                this._typeTxt.text = "";
            }
            return;
        }

        public get skill(): SPetSkill
        {
            return this._skill;
        }

        public set skill(arg1: SPetSkill)
        {
            this._skill = arg1;
            if (this._skill) 
            {
                this._tskill = SkillConfig.instance.getInfoByName(this._skill.skillId);
                if (this._tskill) 
                {
                    this.source = this._tskill.skillIcon + ".jpg";
                }
            }
            else 
            {
                this.source = null;
                this._tskill = null;
            }
            return;
        }

        public /* override */ get toolTipData()
        {
            var loc2=null;
            var loc6=false;
            var loc7=null;
            if (this._type == 1) 
            {
                return this.getUnEnableTipData();
            }
            if (this._type == 2) 
            {
                return Language.getString(28061);
            }
            var loc1="";
            var loc3="";
            var loc4="";
            var loc5="";
            if (this._tskill) 
            {
                loc6 = SkillConfig.instance.isSpecialSkill(this._skill.skillId);
                posType = this._tskill.posType;
                if (posType != 0) 
                {
                    if (posType == 1) 
                    {
                        loc2 = Language.getString(54088);
                    }
                }
                else 
                {
                    loc2 = Language.getString(54087);
                }
                if (this._skill.isGift != 1) 
                {
                    loc4 = "";
                }
                else 
                {
                    loc4 = Language.getString(54139);
                }
                if (this._skill.isSoul != EPetSkillSoul._EPetSkillSoulYes) 
                {
                    loc5 = "";
                }
                else 
                {
                    loc5 = Language.getString(54450);
                }
                loc3 = GameDefConfig.instance.getSkillUseType(this._tskill.useType).name;
                loc1 = loc1 + ("<font color=\'#F5FF00\'size=\'14\'><b>" + this._tskill.skillName + "</b></font><br>");
                if (loc6) 
                {
                    loc7 = "   Lv." + SkillConfig.instance.getSkillLevel(this._tskill.skillId);
                    loc1 = loc1 + HTMLUtil.addColor(loc2 + loc7 + "<br><br>", "#a768c6");
                }
                else 
                {
                    loc1 = loc1 + HTMLUtil.addColor(loc2 + "    " + loc4 + "    " + loc5 + "<br><br>", "#a768c6");
                }
                loc1 = loc1 + HTMLUtil.addColor(this._tskill.skillDescription + "<br><br>", "#ffffff");
                if (this._tskill.skillLevel >= 1 && this._tskill.skillLevel <= 3) 
                {
                    this._nextTSkill = SkillConfig.instance.getInfoByName(this._skill.skillId + 1);
                    if (this._nextTSkill) 
                    {
                        loc1 = loc1 + HTMLUtil.addColor(Language.getString(54140), "#60e71e");
                        loc1 = loc1 + HTMLUtil.addColor(this._nextTSkill.skillName + "\n", "#F5FF00");
                        loc1 = loc1 + HTMLUtil.addColor(this._nextTSkill.skillDescription + "<br><br>", "#ffffff");
                    }
                }
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54090) + loc3 + "<br>", "#f5ff00");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54092) + this._tskill.attackDistance + "<br>", "#f5ff00");
                loc1 = loc1 + (HTMLUtil.addColor(Language.getString(54093) + this._tskill.cooldownTime / 1000 + Language.getString(54089) + "<br>", "#f5ff00") + "<br>");
                if (!loc6) 
                {
                    loc1 = loc1 + Language.getString(54451);
                }
                return new ToolTipInfo(Tooltip.ToolTipRenderType_ShortcutItem, loc1);
            }
            return null;
        }

        /* internal  */onSelectHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.isDig) 
            {
                if (this._skill) 
                {
                    if (this._skill.isGift != EPetSkillSoul._EPetSkillSoulYes) 
                    {
                        if (this._skill.isGift != EPetSkillSoul._EPetSkillSoulNot) 
                        {
                            this.filters = [FilterConst.itemChooseFilter];
                        }
                        else 
                        {
                            this.filters = [new Object /* flash.filters.GlowFilter */(16711680)];
                        }
                    }
                    else 
                    {
                        this.filters = [FilterConst.itemChooseFilter];
                    }
                }
            }
            else 
            {
                this.filters = [FilterConst.itemChooseFilter];
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                if (this.isDig) 
                {
                    if (this._skill) 
                    {
                        if (this._skill.isSoul != EPetSkillSoul._EPetSkillSoulYes) 
                        {
                            if (this._skill.isSoul != EPetSkillSoul._EPetSkillSoulNot) 
                            {
                                if (this._skill.isGift == EPetSkillType._EPetSkillNormal) 
                                {
                                    this.filters = [FilterConst.itemChooseFilter];
                                }
                            }
                            else 
                            {
                                this.filters = [new Object /* flash.filters.GlowFilter */(16711680)];
                            }
                        }
                        else 
                        {
                            this.filters = [FilterConst.itemChooseFilter];
                        }
                    }
                }
                else 
                {
                    this.filters = [FilterConst.itemChooseFilter];
                }
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal  */getUnEnableTipData(): string
        {
            var loc2=0;
            var loc3=0;
            var loc5=0;
            var loc1="";
            var loc4="";
            if (this._petInfo) 
            {
                loc2 = this._petInfo.spirit;
                loc3 = this._petInfo.growth;
                loc5 = this._petInfo.reinLevel;
            }
            if (loc2 < 8) 
            {
                loc1 = loc1 + Language.getString(54600);
            }
            if (loc2 < 12) 
            {
                loc1 = loc1 + Language.getString(54601);
            }
            if (loc3 < 20) 
            {
                loc1 = loc1 + Language.getString(54602);
            }
            if (loc3 < 28) 
            {
                loc1 = loc1 + Language.getString(54603);
            }
            if (loc5 < 1) 
            {
                if (loc1 != "") 
                {
                    loc4 = "\n";
                }
                loc1 = loc1 + (loc4 + Language.getString(28013));
            }
            return "<textFormat leading=\'5\'><font color=\'#ffffff\'>" + loc1 + "</font></textFormat>";
        }

        public get petInfo(): SPetInfo
        {
            return this._petInfo;
        }

        public set petInfo(arg1: SPetInfo)
        {
            this._petInfo = arg1;
            return;
        }

        public /* var */isDig: Boolean=false;

        public /* var */index: int;

        /* internal */ /* var */_type: int;

        /* internal */ /* var */_typeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_skill: SPetSkill;

        /* internal */ /* var */_tskill: TSkill;

        /* internal */ /* var */_nextTSkill: TSkill;

        /* internal */ /* var */_petInfo: SPetInfo;
    }
